#include "xmlBlock.h"

xmlBlock::xmlBlock()
{
    this->isNotRepairable = "false";
    this->depList = new QList<xmlDep *>;
    //this->cdfDip = new QList<QString>;
    this->cdfDip = new QHash<QString,int>;
    this->logicConditionCircleDep = new QHash<int, QString>;
    this->numMergedDep = 0;
    this->idMergedDep = 0;
    this->listIdMergedDep = new QList<int>;
    this->failureDep = new xmlDep();
    this->activeDep = new xmlDep();
}

QString xmlBlock::getTerm1ID()
{
    return this->term1ID;
}

QString xmlBlock::getTerm2ID()
{
    return this->term2ID;
}

QString xmlBlock::getTrigger_block_ID()
{
    return this->trigger_block_ID;
}

QString xmlBlock::getState()
{
    return this->state;
}

QStringList xmlBlock::getTrigger_event_type()
{
    return this->trigger_event_type;
}

QStringList xmlBlock::getReaction_event_type()
{
    return this->reaction_event_type;
}

void xmlBlock::setTerm1ID(QString value)
{
    this->term1ID = value;
}

void xmlBlock::setTerm2ID(QString value)
{
    this->term2ID = value;
}


/*void xmlBlock::setTrigger_block_ID(QString value)
{
    this->trigger_block_ID = value;
}*/


void xmlBlock::setState(QString value)
{
    this->state = value;
}

/*
void xmlBlock::setTrigger_event_type(QStringList head)
{
    this->trigger_event_type = head;
}

void xmlBlock::setReaction_event_type(QStringList head)
{
    this->reaction_event_type = head;
}
*/

void xmlBlock::setIsPainted(bool value)
{
    this->isPainted = value;
}

bool xmlBlock::getIsPainted()
{
    return this->isPainted;
}

QList<xmlDep *> *xmlBlock::getDepList()
{
    return this->depList;
}

void xmlBlock::setDepList(QList<xmlDep *> *value)
{
    this->depList = value;
}

void xmlBlock::setMyNodeConteiner(node * value)
{
    this->myNodeConteiner = value;
}

node * xmlBlock::getMyNodeConteiner()
{
    return this->myNodeConteiner;
}

void xmlBlock::setCdfFailure(QString value)
{
    this->cdfFailure = value;
}

void xmlBlock::setCdfActive(QString value)
{
    this->cdfActive = value;
}

QString xmlBlock::getCdfFailure()
{
    return this->cdfFailure;
}

QString xmlBlock::getCdfActive()
{
    return this->cdfActive;
}

/*QList<QString> *xmlBlock::getCdfDip()
{
    return this->cdfDip;
}

void xmlBlock::setCdfDip(QList<QString> *value)
{
    this->cdfDip = value;
}
*/
QHash<QString,int> *xmlBlock::getCdfDip()
{
    return this->cdfDip;
}

void xmlBlock::setCdfDip(QHash<QString, int> *value)
{
    this->cdfDip = value;
}

void xmlBlock::increaseNumMergedDep()
{
    this->numMergedDep++;
}

void xmlBlock::decreaseNumMergedDep()
{
    this->numMergedDep--;
}

void xmlBlock::setNumMergedDep(int value)
{
    this->numMergedDep = value;
}

int xmlBlock::getNumMergedDep()
{
    return this->numMergedDep;
}

void xmlBlock::setLogicConditionCircleDep(QString condition, int numCircleDep)
{
    this->logicConditionCircleDep->insert(numCircleDep, condition);
}

QString xmlBlock::getLogicConditionCircleDep(int numCircleDep)
{
    return this->logicConditionCircleDep->value(numCircleDep);
}

void xmlBlock::delLogicConditionCircleDep(int numCircleDep)
{
    this->logicConditionCircleDep->remove(numCircleDep);
}

void xmlBlock::increaseIdMergedDep()
{
    this->idMergedDep++;
}

int xmlBlock::getIdMergedDep()
{
    return this->idMergedDep;
}

void xmlBlock::insertListIdMergedDep(int value)
{
    this->listIdMergedDep->append(value);
}

void xmlBlock::setIdMergedDep(int value)
{
    this->idMergedDep = value;
}

void xmlBlock::removeListIdMergedDep(int value)
{
    this->listIdMergedDep->removeOne(value);
}

QList<int> * xmlBlock::getListIdMergedDep()
{
    return this->listIdMergedDep;
}

void xmlBlock::setIds(QStringList ids)
{
    for(int i=0; i<ids.size(); i++)
    {
        bool ok;
        QString id = ids.at(i);
        int value = id.toInt(&ok, 10);
        this->insertListIdMergedDep(value);
    }
    if(!this->listIdMergedDep->isEmpty())
        this->setIdMergedDep(this->listIdMergedDep->last());//aggiorno anche l'intero per l'assegnazione degli id alle mergeDep
}

void xmlBlock::setFailureDep(xmlDep *value)
{
    this->failureDep = value;
}

void xmlBlock::setActiveDep(xmlDep *value)
{
    this->activeDep = value;
}

xmlDep *xmlBlock::getFailureDep()
{
    return this->failureDep;
}

xmlDep *xmlBlock::getActiveDep()
{
    return this->activeDep;
}

void xmlBlock::setIsNotRepairable(QString value)
{
    this->isNotRepairable = value;
}

QString xmlBlock::getIsNotRepairable()
{
    return this->isNotRepairable;
}

void xmlBlock::setX(QString value)
{
    this->x = value.toDouble();
}

void xmlBlock::setY(QString value)
{
    this->y = value.toDouble();
}

double xmlBlock::getX()
{
    return this->x;
}

double xmlBlock::getY()
{
    return this->y;
}
